const orgAssignRoleAPI = {
  getTreeBySelectOrg: param => {
    return $http
      .get(`${window.RPConfig.mgt}/dataPolicyAssignmentBiz/getTreeBySelectOrg`, param)
      .then(response => response.data);
  },
  queryOrgRootNode: param => {
    if (param) {
      // 数据权限用这个接口
      return $http
        .post(`${window.RPConfig.mgt}/dataPolicyAssignmentBiz/getOrgByUserId`, param)
        .then(response => response.data);
    } else {
      // 角色分配用这个接口
      return $http
        .post(`${window.RPConfig.mgt}/organization/getOrgTreeByUser?orgType=${2}`, {})
        .then(response => response.data);
    }
  },
  queryOrgTree: param => {
    return $http
      .post(
        `${window.RPConfig.mgt}/organization/getOrgTreeByUser?orgType=${2}&enabled=${1}&nameOrCode=${param.nameOrCode}`,
        param
      )
      .then(response => response.data);
  },
  queryOrgChildrenNode: (orgId, dimensionRelId) => {
    if (dimensionRelId) {
      // 数据权限用这个接口
      return $http
        .post(
          `${window.RPConfig.mgt}/dataPolicyAssignmentBiz/getSubOrganizationByPid?orgId=${orgId}&dimensionRelId=${dimensionRelId}`,
          {}
        )
        .then(response => response.data);
    } else {
      // 角色分配用这个接口
      return $http
        .post(`${window.RPConfig.mgt}/role/getSubOrganization?orgId=${orgId}`, {})
        .then(response => response.data);
    }
  },
  queryOrgDeptNode: () => {
    // 停用这个接口，改为懒加载接口queryOrgRootNode
    return $http.post(`${window.RPConfig.mgt}/role/getOrgDeptByUserId`, {}).then(response => response.data);
  },
  findOrgNode: nameOrCode => {
    return $http
      .get(`${window.RPConfig.mgt}/organization/findOrganizationByConditionByRole?nameOrCode=${nameOrCode}`, {})
      .then(response => response.data);
  },
  // queryAssignedRole: orgId => {
  //   return $http
  //     .post(`${window.RPConfig.mgt}/role/org/getRoleByOrgId?orgId=${orgId}`, {})
  //     .then(response => response.data);
  // },
  queryAssignedRole: param => {
    return $http.post(`${window.RPConfig.mgt}/role/org/getRoleByOrgId`, param).then(response => response.data);
  },
  queryUnassignedRole: param => {
    return $http.post(`${window.RPConfig.mgt}/role/org/list/page`, param).then(response => response.data);
  },
  saveAssignedRole: param => {
    return $http.post(`${window.RPConfig.mgt}/role/org/save`, param).then(response => response.data);
  },
  deleteAssignedRole: param => {
    return $http.post(`${window.RPConfig.mgt}/role/org/delete`, param).then(response => response.data);
  },
  queryAssignedUser: param => {
    return $http.post(`${window.RPConfig.mgt}/role/orgUser/getRoleByOrgId`, param).then(response => response.data);
  },
  //角色分配-查询已分配用户接口改为分页新接口
  getAssignedUser: param => {
    return $http.post(`${window.RPConfig.mgt}/role/orgUser/getRoleByOrgId/page`, param).then(response => response.data);
  },
  queryUnassignedUser: param => {
    return $http.post(`${window.RPConfig.mgt}/role/orgUser/page`, param).then(response => response.data);
  },
  queryAssignedUserRole: param => {
    return $http.post(`${window.RPConfig.mgt}/role/getRoleByUserIds`, param).then(response => response.data);
  },
  getAssignedUserRole: param => {
    return $http.post(`${window.RPConfig.mgt}/role/getOrgRoleByUserIds`, param).then(response => response.data);
  },
  saveAssignedUser: param => {
    return $http.post(`${window.RPConfig.mgt}/role/orgUser/save`, param).then(response => response.data);
  },
  deleteAssignedUser: param => {
    return $http.post(`${window.RPConfig.mgt}/role/orgUser/delete`, param).then(response => response.data);
  },
  // 根据角色、组织查询以分配的数据权限
  queryAccessTypeInfo: param => {
    return $http.post(`${window.RPConfig.mgt}/role/authData/get`, param).then(response => response.data);
  },
  // 保存数据权限
  saveDataAccess: param => {
    return $http.post(`${window.RPConfig.mgt}/role/authData/save`, param).then(response => response.data);
  }
};
export default orgAssignRoleAPI;
